""""商品类目创建页面"""

from page_objects.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from utils.log import logger
from utils.utils_click import click_execption


class CategoryCreatePage(BasePage):
    __CATEGORY_NAME = (By.CSS_SELECTOR, '.el-input__inner')
    __CLICK_QUEDING = (By.CSS_SELECTOR, ".dialog-footer .el-button--primary")


    def creat(self, categroy_name):
        # 输入商品类目名称
        # self.driver.find_element(By.CSS_SELECTOR, '.el-input__inner').send_keys("海贼王")
        self.do_send_key(categroy_name, self.__CATEGORY_NAME)
        # 点击确定
        # self.driver.find_element(By.XPATH, "//*[text()='确定']").click()
        WebDriverWait(self.driver, 10).until(click_execption(*self.__CLICK_QUEDING))
        self.do_find(self.__CLICK_QUEDING).click()
        # ==》 类目列表页面
        from page_objects.category_list_page import CategoryListPage
        return CategoryListPage(self.driver)


